using System;
using UnityEngine;

namespace StarForce.Hotfix
{
    public abstract class ItemContext
    {
        
        private GameObject m_GameObject;

        public GameObject GameObject
        {
            get { return m_GameObject; }
            set { m_GameObject = value; }
        }

        private int m_Index;

        public int Index
        {
            get { return m_Index; }
            internal set { m_Index = value; }
        }
        
        private Action<ItemContext> m_OnItemClick;

        public event Action<ItemContext> OnItemClick
        {
            add
            {
                m_OnItemClick -= value; 
                m_OnItemClick += value;
            }
            remove { m_OnItemClick -= value; }
        }

        public virtual void Click()
        {
            if (m_OnItemClick != null)
            {
                m_OnItemClick.Invoke(this);
            }
        }

        public virtual void Clear()
        {
            m_OnItemClick = null;
        }

        public abstract void Init();

        public abstract void GetBindComponents();

    }
}